#pragma once


#include "HashTable.h"


namespace what
{
	template<class K, class V, class Hash = HashFunc<K>>
	class unordered_map
	{
	private:
		struct MapKeyOfT
		{
			const K& operator()(const std::pair<K, V>& kv)
			{
				return kv.first;
			};
		};

	public:
		typedef typename hash_bucket::HashTable<K, std::pair<const K, V>, MapKeyOfT, Hash>::iterator iterator;

		iterator begin()
		{
			return _ht.begin();
		}

		iterator end()
		{
			return _ht.end();
		}

		std::pair<iterator, bool> insert(const std::pair<K, V>& data)
		{
			return _ht.Insert(data);
		}

		V& operator[](const K& key)
		{
			return *(_ht.Insert({ key, V() }).first).second;
		}

	private:
		hash_bucket::HashTable<K, std::pair<const K, V>, MapKeyOfT, Hash> _ht;
	};
}